package com.spit.amoeba.bean.dao

import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import com.spit.amoeba.bean.db.UploadOrderListBean

/**
 * @Author nike
 * @Date 2023/9/13 17:49
 * @Description
 */
@Dao
interface UploadOrderListDao {

    /**
     * 增加
     */
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    fun add(vararg bean: UploadOrderListBean)

    @Query("SELECT * FROM UploadOrderListBean")
    fun findAll(): List<UploadOrderListBean>

    @Query("SELECT * FROM UploadOrderListBean WHERE orderId = :orderId")
    fun findById(orderId: String): UploadOrderListBean

    @Query("SELECT * FROM UploadOrderListBean WHERE type = :type")
    fun findTypeAll(type: Int): List<UploadOrderListBean>

    /**
     * 根据用户ID删除
     */
    @Query("DELETE FROM UploadOrderListBean WHERE type = :type")
    suspend fun deleteById(type: Int?)

    /**
     * 根据用户ID删除
     */
    @Query("DELETE FROM UploadOrderListBean WHERE orderId = :orderId")
    suspend fun deleteById(orderId: String?)

    //删除数据库表全部数据
    @Query("delete from UploadOrderListBean")
    suspend fun deleteAll()

}